package com.mtsmda.chapter3;

import java.awt.Dimension;
import java.util.Date;

public class Run {

	static int ik;
	double d15;
	Date date;
	String [] strings;
	
	@SuppressWarnings("unused")
	public static void main(String[] args) {
		
		/////
		int i1[] = new int[]{152, 0253, 0x15Df, 02523, 0x825FD};
		for(int i : i1){
			System.out.println(i);
		}
		System.out.println("_____");
		long l1[] = new long[]{1525824L, 1551, 025335L, 0x25dced};
		for(long l : l1){
			System.out.println(l);
		}
		
		System.out.println("_____");
		char c1[] = new char[]{1525, 1551, (char)025335, 0x25dc, '\n', '\"'};
		for(char c : c1){
			System.out.println(c);
		}
		
		byte b3 = 3;
		byte b9 = 9;
		byte sum = (byte) (b3 + b9);
		byte sumSum = (byte) (sum + 11);
		
		int i100 = 100;
		long l100 = i100;
//		System.out.println(l100 instanceof Long);
		
		float f = 100.025F;
		int if1 = (int) f;
		System.out.println("f = " + f + "\n" + "if1 = " + if1);
		
		long l2 = 256L;
		byte b2 = (byte)l2;
		System.out.println(l2 + " - " + b2);
		
		float f234 = 234.56F;
		short s234 = (short)f234; 
		System.out.println(f234 + " - " + s234);
		byte b128 = (byte)-129;
		System.out.println(b128);
		
		byte b7 = 7;
		b7 += 9;
		System.out.println(b7);
		
		int iC1 = 9;
		int iC2 = iC1;
		System.out.println(iC1 == iC2);
		Integer integer1 = new Integer(9);
		Integer integer2 = new Integer(9);
		System.out.println(integer1.equals(integer2));
		System.out.println(integer1 == integer2);
		System.out.println(("a" == "a"));
		System.out.println(("a" == "b"));
		System.out.println(("a".equals("a")));
		System.out.println();
		new Run().go();
		System.out.println("*******");
		boolean b [] = new boolean[5];
		for(boolean bb : b){
			System.out.println(bb);
		}
		
		String s [] = new String[5];
		s[3] = new String("JAVA");
		for(String st : s){
			if(st != null)
			System.out.println(st);
		}
		System.out.println("char");
		char c [] = new char[5];
		for(char cc : c){
			System.out.println(cc);
		}
		int cv = 0;
		System.out.println(cv);
		
//		int gc [] = null;
//		System.out.println(gc.length);java.lang.NullPointerException
		int gc [] = new int[15];
		System.out.println(gc != null);
		System.out.println(gc.length);
		System.out.println("*********");
		new Run().go3();
//		Date date;
		Date date = null;
		if(date == null){
			System.out.println("date is not initialized");
		}
		System.out.println(new Run().date);
		System.out.println(new Run().strings);
//		String [] str;
		String [] str = null;
		System.out.println(str);
		System.out.println("*************************************");
		
		Dimension dA = new Dimension();
		dA.width = 15;
		dA.height = 50;
		Dimension dB = dA;
		System.out.println("a.w = " + dA.width + " - " + "a.h = " + dA.height);
		System.out.println("b.w = " + dB.width + " - " + "b.h = " + dB.height);
		dA.width = 150;
		dB.height = 500;
		System.out.println("a.w = " + dA.width + " - " + "a.h = " + dA.height);
		System.out.println("b.w = " + dB.width + " - " + "b.h = " + dB.height);
		
		System.out.println("*************************************");
		stringEx();
	}
	
	void go3(){
		System.out.println(ik);
		ik+=10;
		System.out.println(ik);
		System.out.println(d15);
		d15+=15.15;
		System.out.println(d15);
	}
	
	void go(){
		int y = 0;
		Integer interger = new Integer(0);
		String string = new String("s");
		StringBuilder builder = new StringBuilder(string);
		System.out.println(builder.equals(string));
		int intAr [] = new int[5];
//		System.out.println(builder == string);
		go2(y, interger, string, builder, intAr);
		System.out.println(y);
		System.out.println(interger);
		System.out.println(string);
		System.out.println(builder);
		for(int i : intAr){
			System.out.println(i);
		}
	}
	
	void go2(int y, Integer i, String s, StringBuilder builder, int intAr []){
		y++;
		i++;
		s += "inS";
		builder.append("inSBuilder");
		intAr[intAr.length - 1] = 999;
	}

	static void stringEx(){
		String s = "s";
		String s1 = s;
		System.out.println("begin " + (s == s1));
		System.out.println(s.equals(s1));
		System.out.println("s = " + s);
		System.out.println("s1 = " + s1);
		s1+="2s";
		System.out.println("s = " + s);
		System.out.println("s1 = " + s1);
		System.out.println("end " + (s == s1));
		System.out.println(s.equals(s1));
	}
}